<%@ page import="com.ws.lv.util.Res" %><%--
  Created by IntelliJ IDEA.
  User: Adminis
  Date: 2025/3/19
  Time: 11:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人主页</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/home/css/bootstrap.min.css">
    <script src="${pageContext.request.contextPath}/home/js/bootstrap.min.js"></script>
    <style>
        body {
            background-image: url("${pageContext.request.contextPath}/home/images/Kitty2.png");
            background-size: cover;
            background-repeat: no-repeat;
        }

        .thmym {
            margin: 0 auto;
            width: 1200px;
            height: 800px;
            background-color: rgba(0, 0, 0, 0.5);
            border-radius: 80px;
            transition: box-shadow 0.3s ease; /* 添加过渡效果 */
        }

        .thmym:hover {
            box-shadow: 0 0 20px rgba(255, 255, 255, 0.8); /* 鼠标划过时的发光效果 */
        }

        .head {
            font-size: 28px;
            font-weight: 800;
            color: wheat;
            text-align: center;
            font-family: 'Roboto', sans-serif; /* 使用Google Fonts中的Roboto字体 */
            transition: text-shadow 0.3s ease; /* 添加过渡效果 */
        }

        .head:hover {
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.8); /* 鼠标划过时的发光效果 */
        }

        .form-control {
            background-color: rgba(255, 255, 255, 0.1);
            color: #202020;
            border: 1px solid #fffafa;
        }

        .form-control:focus {
            background-color: rgba(255, 255, 255, 0.2);
            border-color: #fffb13;
            color: #fffafa;
            outline: none;
        }

        .tx {
            width: 150px;
            height: 150px;
            border-radius: 50%;
        }

        .left {
            float: left;
            width: 600px;
            height: 800px;
            padding: 0px 50px;
            border-right: 2px ridge rgba(39, 38, 38, 0.8);
        }

        .left .myimg {
            margin-top: 50px;
            text-align: center;
            font-family: 'Roboto', sans-serif; /* 使用Google Fonts中的Roboto字体 */
            transition: text-shadow 0.3s ease; /* 添加过渡效果 */

        }

        .left .myimg:hover {
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.8); /* 鼠标划过时的发光效果 */
        }

        label {
            color: #fffb13;
        }

        .btn {
            margin-top: 20px;
            background-color: rgba(255, 255, 255, 0.2);
            color: aqua;
            border: 0px;
        }

        #txImage {
            display: none;
        }

        .xg:hover {
            background-color: rgba(50, 228, 252, 0.329);
            color: yellow;
        }

        .bc {
            display: none;
        }

        .bc:hover {
            background-color: rgba(247, 235, 71, 0.329);
            color: rgb(81, 255, 28);
        }

        .right {
            float: left;
            width: 600px;
            height: 800px;
            padding: 0px 50px;
            border-left: 4px dotted rgba(39, 38, 38, 0.8);
        }

        .right ul {
            padding: 0px;
            margin-top: 30px;
        }

        .right ul li {
            list-style: none;
            height: 60px;
            line-height: 60px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.329);
            font-family: 'Roboto', sans-serif; /* 使用Google Fonts中的Roboto字体 */
            transition: text-shadow 0.3s ease; /* 添加过渡效果 */
        }

        .right ul li:hover {
            border-radius: 20px;
            background-color: rgba(255, 255, 255, 0.295);
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.8); /* 鼠标划过时的发光效果 */
        }

        .right ul li a {
            text-decoration: none;
            color: rgb(253, 249, 188);
            font-size: 24px;
        }

        #shouye img {
            width: 30px;
            height: 30px;
            vertical-align: middle;
            margin-bottom: 6px;
        }
        #shouye button{
            font-size: 24px;
        }



    </style>
    <c:if test="${u == null}">
        <script>
            window.parent.location.href = "${pageContext.request.contextPath}/homepage/toHomeLogin";
        </script>
    </c:if>
</head>
<body>
<div class="container">
    <p class="head">个人主页</p>
    <div class="thmym">
        <div class="left">
            <div class="myimg">
                <img class="tx" src="<%=Res.homeTxFileUrl%>${u.user_tx}" alt="头像"></img>
                <p style="color: wheat; font-size: 18px;">${u.user_name}</p>
            </div>

            <form action="${pageContext.request.contextPath}/homepage/updateUser" enctype="multipart/form-data" method="post">
                <!-- 用户名 -->
                <div class="form-group ">
                    <label for="exampleInputUsername">用户名</label>
                    <input type="text" class="form-control" id="exampleInputUsername" value="${u.user_name}" readonly
                           placeholder="用户名" name="user_name">
                </div>
                <!-- 手机号 -->
                <div class="form-group">
                    <label for="exampleInputPhone">手机号</label>
                    <input type="text" class="form-control" id="exampleInputPhone" value="${u.user_phone}" readonly
                           placeholder="手机号" name="user_phone">
                </div>
                <!-- 生日 -->
                <div class="form-group">
                    <label for="exampleInputBirthday">生日</label>
                    <input type="date" class="form-control" id="exampleInputBirthday"
                           value="<fmt:formatDate value="${u.user_birthday}" pattern="yyyy-MM-dd"/>" readonly placeholder="生日" name="user_birthday">

                </div>
                <!-- 头像 -->
                <div class="form-group" id="txImage">
                    <label for="exampleInputFile">头像</label>
                    <input type="file" class="form-control" id="exampleInputFile" aria-describedby="fileHelp" name="newUserTx">
                </div>

                <button type="button" class="btn btn-primary btn-sm btn-block xg" onclick="xg()">修改</button>
                <button type="submit" class="btn btn-primary btn-sm btn-block bc">保存</button>
            </form>
        </div>
        <div class="right">
            <ul>
                <li>
                    <a href="${pageContext.request.contextPath}/homepage/toDingdan">
                        <img src="${pageContext.request.contextPath}/home/images/dingdan.png" alt=""
                             style="width: 30px; height: 30px; vertical-align: middle;">
                        我的订单
                    </a>
                </li>
                <li>
                    <a href="${pageContext.request.contextPath}/homepage/toMyfavorite">
                        <img src="${pageContext.request.contextPath}/home/images/shoucang.png" alt=""
                             style="width: 30px; height: 30px; vertical-align: middle;">
                        我的收藏
                    </a>
                </li>
                <li>
                    <a href="${pageContext.request.contextPath}/homepage/toUpdateUserPass">
                        <img src="${pageContext.request.contextPath}/home/images/xiugaimima.png" alt=""
                             style="width: 30px; height: 30px; vertical-align: middle;">
                        修改密码
                    </a>
                </li>
                <li>
                    <a href="${pageContext.request.contextPath}/user/qiehuan">
                        <img src="${pageContext.request.contextPath}/home/images/qiehuan.png" alt=""
                             style="width: 30px; height: 30px; vertical-align: middle;">
                        切换账号
                    </a>
                </li>
                <li>
                    <a href="${pageContext.request.contextPath}/user/outLogin">
                        <img src="${pageContext.request.contextPath}/home/images/tuichu.png" alt=""
                             style="width: 30px; height: 30px; vertical-align: middle;">
                        退出登录
                    </a>
                </li>
                <li>
                    <a href="${pageContext.request.contextPath}/user/zhuxiao">
                        <img src="${pageContext.request.contextPath}/home/images/zhuxiao.png" alt=""
                             style="width: 30px; height: 30px; vertical-align: middle;">
                        注销账户
                    </a>
                </li>

            </ul>
            <a href="${pageContext.request.contextPath}/homepage/toHomePage" id="shouye">
                <button type="button" class="btn btn-primary btn-sm btn-block">
                    <img src="${pageContext.request.contextPath}/home/images/shouye.png">返回首页
                </button>
            </a>


        </div>
    </div>
</div>
</body>
</html>
<script>
    function xg() {
        // 获取所有输入框
        var inputs = document.querySelectorAll('.form-control');
        inputs.forEach(function (input) {
            input.readOnly = false;
        });

        // 显示头像上传输入框
        document.getElementById("txImage").style.display = "block";

        // 禁用修改按钮
        document.querySelector('.xg').disabled = true;

        // 启用保存按钮
        document.querySelector('.bc').disabled = false;

        //隐藏修改按钮
        document.querySelector('.xg').style.display = "none";
        //显示保存按钮
        document.querySelector('.bc').style.display = "block";
    }

    function bc() {
        // 这里可以添加保存逻辑
        // alert('保存成功！');

        // 启用修改按钮
        document.querySelector('.xg').disabled = false;

        // 禁用保存按钮
        document.querySelector('.bc').disabled = true;

        // 获取所有输入框
        var inputs = document.querySelectorAll('.form-control');
        inputs.forEach(function (input) {
            input.readOnly = true;
        });

        // 隐藏头像上传输入框
        document.getElementById("txImage").style.display = "none";

        //隐藏保存按钮
        document.querySelector('.bc').style.display = "none";
        //显示修改按钮
        document.querySelector('.xg').style.display = "block";

    }
</script>